<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Amaze UI Admin index Examples</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="/static/admin/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="/static/admin/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <script src="/static/admin/js/echarts.min.js"></script>
    <link rel="stylesheet" href="/static/admin/css/amazeui.min.css"/>
    <link rel="stylesheet" href="/static/admin/css/amazeui.datatables.min.css"/>
    <link rel="stylesheet" href="/static/admin/css/bootstrap.css">
    <link rel="stylesheet" href="/static/admin/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/admin/css/app.css">
    <script src="/static/admin/js/jquery.min.js"></script>

</head>

<body data-type="widgets">
<script src="/static/admin/js/theme.js"></script>
<div class="am-g tpl-g">
    <!-- 头部 -->
    <header>
        <!-- logo -->
        <div class="am-fl tpl-header-logo">
            <a href="javascript:;"><img src="/static/admin/img/logo.png" alt=""></a>
        </div>
        <!-- 右侧内容 -->
        <div class="tpl-header-fluid">
            <!-- 侧边切换 -->
            <div class="am-fl tpl-header-switch-button am-icon-list">
                    <span>

                </span>
            </div>
            <!-- 搜索 -->
            <div class="am-fl tpl-header-search">
                <form class="tpl-header-search-form" action="javascript:;">
                    <button class="tpl-header-search-btn am-icon-search"></button>
                    <input class="tpl-header-search-box" type="text" placeholder="搜索内容...">
                </form>
            </div>
            <!-- 其它功能-->
            <div class="am-fr tpl-header-navbar">
                <ul>
                    <!-- 欢迎语 -->
                    <li class="am-text-sm tpl-header-navbar-welcome">
                        <a href="javascript:;">欢迎你, <span>Amaze UI</span> </a>
                    </li>

                    <!-- 新邮件 -->
                    <li class="am-dropdown tpl-dropdown" data-am-dropdown>
                        <a href="javascript:;" class="am-dropdown-toggle tpl-dropdown-toggle" data-am-dropdown-toggle>
                            <i class="am-icon-envelope"></i>
                            <span class="am-badge am-badge-success am-round item-feed-badge">4</span>
                        </a>
                        <!-- 弹出列表 -->
                        <ul class="am-dropdown-content tpl-dropdown-content">
                            <li class="tpl-dropdown-menu-messages">
                                <a href="javascript:;" class="tpl-dropdown-menu-messages-item am-cf">
                                    <div class="menu-messages-ico">
                                        <img src="/static/admin/img/user04.png" alt="">
                                    </div>
                                    <div class="menu-messages-time">
                                        3小时前
                                    </div>
                                    <div class="menu-messages-content">
                                        <div class="menu-messages-content-title">
                                            <i class="am-icon-circle-o am-text-success"></i>
                                            <span>夕风色</span>
                                        </div>
                                        <div class="am-text-truncate"> Amaze UI 的诞生，依托于 GitHub 及其他技术社区上一些优秀的资源；Amaze UI
                                            的成长，则离不开用户的支持。
                                        </div>
                                        <div class="menu-messages-content-time">2016-09-21 下午 16:40</div>
                                    </div>
                                </a>
                            </li>

                            <li class="tpl-dropdown-menu-messages">
                                <a href="javascript:;" class="tpl-dropdown-menu-messages-item am-cf">
                                    <div class="menu-messages-ico">
                                        <img src="/static/admin/img/user02.png" alt="">
                                    </div>
                                    <div class="menu-messages-time">
                                        5天前
                                    </div>
                                    <div class="menu-messages-content">
                                        <div class="menu-messages-content-title">
                                            <i class="am-icon-circle-o am-text-warning"></i>
                                            <span>禁言小张</span>
                                        </div>
                                        <div class="am-text-truncate"> 为了能最准确的传达所描述的问题， 建议你在反馈时附上演示，方便我们理解。</div>
                                        <div class="menu-messages-content-time">2016-09-16 上午 09:23</div>
                                    </div>
                                </a>
                            </li>
                            <li class="tpl-dropdown-menu-messages">
                                <a href="javascript:;" class="tpl-dropdown-menu-messages-item am-cf">
                                    <i class="am-icon-circle-o"></i> 进入列表…
                                </a>
                            </li>
                        </ul>
                    </li>

                    <!-- 新提示 -->
                    <li class="am-dropdown" data-am-dropdown>
                        <a href="javascript:;" class="am-dropdown-toggle" data-am-dropdown-toggle>
                            <i class="am-icon-bell"></i>
                            <span class="am-badge am-badge-warning am-round item-feed-badge">5</span>
                        </a>

                        <!-- 弹出列表 -->
                        <ul class="am-dropdown-content tpl-dropdown-content">
                            <li class="tpl-dropdown-menu-notifications">
                                <a href="javascript:;" class="tpl-dropdown-menu-notifications-item am-cf">
                                    <div class="tpl-dropdown-menu-notifications-title">
                                        <i class="am-icon-line-chart"></i>
                                        <span> 有6笔新的销售订单</span>
                                    </div>
                                    <div class="tpl-dropdown-menu-notifications-time">
                                        12分钟前
                                    </div>
                                </a>
                            </li>
                            <li class="tpl-dropdown-menu-notifications">
                                <a href="javascript:;" class="tpl-dropdown-menu-notifications-item am-cf">
                                    <div class="tpl-dropdown-menu-notifications-title">
                                        <i class="am-icon-star"></i>
                                        <span> 有3个来自人事部的消息</span>
                                    </div>
                                    <div class="tpl-dropdown-menu-notifications-time">
                                        30分钟前
                                    </div>
                                </a>
                            </li>
                            <li class="tpl-dropdown-menu-notifications">
                                <a href="javascript:;" class="tpl-dropdown-menu-notifications-item am-cf">
                                    <div class="tpl-dropdown-menu-notifications-title">
                                        <i class="am-icon-folder-o"></i>
                                        <span> 上午开会记录存档</span>
                                    </div>
                                    <div class="tpl-dropdown-menu-notifications-time">
                                        1天前
                                    </div>
                                </a>
                            </li>


                            <li class="tpl-dropdown-menu-notifications">
                                <a href="javascript:;" class="tpl-dropdown-menu-notifications-item am-cf">
                                    <i class="am-icon-bell"></i> 进入列表…
                                </a>
                            </li>
                        </ul>
                    </li>

                    <!-- 退出 -->
                    <li class="am-text-sm">
                        <a href="javascript:;">
                            <span class="am-icon-sign-out"></span> 退出
                        </a>
                    </li>
                </ul>
            </div>
        </div>

    </header>
    <!-- 风格切换 -->
    <div class="tpl-skiner">
        <div class="tpl-skiner-toggle am-icon-cog">
        </div>
        <div class="tpl-skiner-content">
            <div class="tpl-skiner-content-title">
                选择主题
            </div>
            <div class="tpl-skiner-content-bar">
                <span class="skiner-color skiner-white" data-color="theme-white"></span>
                <span class="skiner-color skiner-black" data-color="theme-black"></span>
            </div>
        </div>
    </div>
    <!-- 侧边导航栏 -->
    <div class="left-sidebar">
        <!-- 用户信息 -->
        <div class="tpl-sidebar-user-panel">
            <div class="tpl-user-panel-slide-toggleable">
                <div class="tpl-user-panel-profile-picture">
                    <img src="/static/admin/img/user04.png" alt="">
                </div>
                <span class="user-panel-logged-in-text">
              <i class="am-icon-circle-o am-text-success tpl-user-panel-status-icon"></i>
              禁言小张
          </span>
                <a href="javascript:;" class="tpl-user-panel-action-link"> <span class="am-icon-pencil"></span> 账号设置</a>
            </div>
        </div>


        <!-- 菜单 -->
        <ul class="sidebar-nav">
            <li class="sidebar-nav-heading">Components <span class="sidebar-nav-heading-info"> 附加组件</span></li>
            <li class="sidebar-nav-link">
                    <a href="{:url('admin/index/index')}" class="active">
                        <i class="am-icon-home sidebar-nav-link-logo"></i> 首页
                    </a>
                </li>
                <li class="sidebar-nav-link">
                    <a href="{:url('admin/vipuser/index')}">
                        <i class="am-icon-table sidebar-nav-link-logo"></i> 会员管理
                    </a>
                </li>
                
                <li class="sidebar-nav-link">
                    <a href="{:url('admin/syauser/index')}">
                        <i class="am-icon-table sidebar-nav-link-logo"></i> 管理员管理
                    </a>
                </li>

                <li class="sidebar-nav-link">
                    <a href="{:url('admin/teacher/index')}">
                        <i class="am-icon-table sidebar-nav-link-logo"></i> 教师列表
                    </a>
                </li>
                
                <!--商品管理!!!!!-->
                <li class="sidebar-nav-link">
                    <a   class="sidebar-nav-sub-title">
                        <i class="am-icon-table sidebar-nav-link-logo"></i> 商品管理
                        <span class="am-icon-chevron-down am-fr am-margin-right-sm sidebar-nav-sub-ico"></span>
                    </a>
                    <ul class="sidebar-nav sidebar-nav-sub">
                        <li class="sidebar-nav-link">
                            <a href="{:url('admin/goods/index')}" class="sub-active">
                                <span class="am-icon-angle-right sidebar-nav-link-logo"></span> 商品列表
                            </a>
                        </li>
                        <li class="sidebar-nav-link">
                            <a href="{:url('admin/goods/create')}">
                                <span class="am-icon-angle-right sidebar-nav-link-logo"></span> 商品添加
                            </a>
                        </li>

                    </ul>
                </li>

                    <!--分类管理!!!!!!-->
                <li class="sidebar-nav-link">
                    <a class="sidebar-nav-sub-title">
                        <i class="am-icon-table sidebar-nav-link-logo"></i> 分类管理
                        <span class="am-icon-chevron-down am-fr am-margin-right-sm sidebar-nav-sub-ico"></span>
                    </a>
                    <ul class="sidebar-nav sidebar-nav-sub">
                        <li class="sidebar-nav-link">
                            <a href="{:url('admin/goodscate/index')}" class="sub-active">
                                <span class="am-icon-angle-right sidebar-nav-link-logo"></span> 分类列表
                            </a>
                        </li>
                        <li class="sidebar-nav-link">
                            <a href="{:url('admin/goodscate/create')}">
                                <span class="am-icon-angle-right sidebar-nav-link-logo"></span> 分类添加
                            </a>
                        </li>
                    </ul>
                </li>
            <li class="sidebar-nav-link">
                <a href="404.html">
                    <i class="am-icon-tv sidebar-nav-link-logo"></i> 404错误
                </a>
            </li>

        </ul>
    </div>


    <!-- 内容区域 -->
    <div class="tpl-content-wrapper">

        <div class="container-fluid am-cf">
            <div class="row">
                <div class="am-u-sm-12 am-u-md-12 am-u-lg-9">
                    <div class="page-header-heading"><span class="am-icon-home page-header-heading-icon"></span> 教师信息
                        <small>Teacher</small>
                    </div>
                    <p class="page-header-description"></p>
                </div>
                <div class="am-u-lg-3 tpl-index-settings-button">
                    <button href="" style="float: right;position: relative;top: 50px;"
                            class="am-btn am-btn-success am-btn-xn am-radius" id="doc-prompt-toggle">添加教师
                    </button>
                    <!--<button-->
                    <!--type="button"-->
                    <!--class="am-btn am-btn-success"-->
                    <!--id="doc-prompt-toggle">-->
                    <!--Prompt-->
                    <!--</button>-->
                </div>
            </div>
        </div>
        <div class="row-content am-cf">

            <div class="row">

                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <div class="widget-head am-cf">
                            <div class="widget-title am-fl">教师列表</div>
                            <div class="widget-function am-fr">
                                <a href="javascript:;" class="am-icon-cog"></a>
                            </div>
                        </div>
                        <div class="widget-body  widget-body-lg am-fr">

                            <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black "
                                   id="example-r">
                                <tr>
                                    <th>ID</th>
                                    <th>姓名</th>
                                    <th>性别</th>
                                    <th>年龄</th>
                                    <th>手机号</th>
                                    <th>教学种类</th>
                                    <th>简介</th>
                                    <th>编辑</th>
                                </tr>
                                {volist name="list" id="v" }
                                <tr>
                                    <td>{$v['id']}</td>
                                    <td>{$v['tch_name']}</td>
                                    <td>
                                        {if ($v['tch_sex'] == 0)}女
                                        {elseif ($v['tch_sex'] == 1)}男
                                        {/if}
                                    </td>


                                    <td>{$v['tch_age']}</td>
                                    <td>{$v['tch_phone']}</td>
                                    <td>{$v['tch_type']}</td>
                                    <td>{$v['tch_detail']}</td>
                                    <td class="">
                                        <a href="{:url('admin/teacher/edit',['id'=>$v['id']])}" data-id="{$v['id']}"
                                           class="am-btn am-btn-primary am-btn-xs am-radius edi-btn">编辑</a>

                                        <button data-id="{$v['id']}"
                                                class="am-btn am-btn-danger am-btn-xs am-radius del-btn">删除
                                        </button>
                                        <!--<button-->
                                        <!--class="am-btn am-btn-primary"-->
                                        <!--data-am-modal="{target: '#my-alert'}">-->
                                        <!--Alert-->
                                        <!--</button>-->
                                    </td>
                                </tr>
                                {/volist}

                                <!-- more data -->

                            </table>
                            <div class="am-fr">
                                <ul class="am-pagination am-pagination-right">
                                    {$page}
                                </ul>
                            </div>
                        </div>

                    </div>
                </div>
            </div>

        </div>
    </div>
    <form action="{:url('admin/teacher/save')}" method="post" name="myform" class="form-horizontal"
          onsubmit="return checkForm()">
        <div class="am-modal am-modal-prompt" tabindex="-1" id="my-prompt">
            <div class="am-modal-dialog" style="width: 500px;">
                <div class="form-group" style="height:30px;">
                    <label class="col-sm-5 control-label"><h3>添加教师</h3></label>
                </div>
                <br>
                <div class="form-group">
                    <label class="col-sm-2 control-label">姓名</label>
                    <div class="col-sm-10">
                        <input name="tch_name" class="form-control input_sm " onblur="checkUser()" style="width: 360px"
                               placeholder="姓名">
                        <div id="utab" style="float:left; font-size: 10px; height:10px;"></div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">性别</label>
                    <label style="margin-right: 330px" class="radio-inline">
                        <input type="radio" name="tch_sex" value="1" checked> 男
                    </label>
                    <label style="margin-right: 250px" class="radio-inline">
                        <input type="radio" name="tch_sex" value="0"> 女
                    </label>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">年龄</label>
                    <div class="col-sm-10">
                        <input name="tch_age" class="form-control" onblur="checkAge()" style="width: 360px"
                               placeholder="年龄">
                        <div id="atab" style="float:left; font-size: 10px; height:10px;"></div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">手机号</label>
                    <div class="col-sm-10">
                        <input name="tch_phone" style="width: 360px;" onblur="checkPhone()" class="form-control"
                               placeholder="手机号">
                        <div id="pptab" style="float:left; font-size: 10px; height:10px;"></div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">教学</label>
                    <div class="col-sm-10">
                        <input name="tch_type" style="width: 360px;" class="form-control" placeholder="教学种类">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">简介</label>
                    <div class="col-sm-10">
                        <input name="tch_detail" style="width: 360px;" class="form-control" placeholder="教师简介">
                    </div>
                </div>
                <button style="margin-top: 50px" class="am-btn am-btn-primary am-radius am-btn-lg">添加</button>
                <a style="margin-top: 50px" href="{:url('admin/teacher/index')}" class="am-btn am-btn-danger am-btn-lg">取消</a>
            </div>
        </div>
    </form>

    <script src="/static/admin/js/amazeui.min.js"></script>
    <script src="/static/admin/js/amazeui.datatables.min.js"></script>
    <script src="/static/admin/js/dataTables.responsive.min.js"></script>
    <script src="/static/admin/js/app.js"></script>


    <script>
        $(function () {
//        触发用户删除操作
            $('.del-btn').click(function () {
                var ac_id = $(this).attr('data-id');
                console.log(ac_id);
                if (confirm('你确定要[[删除]]该用户么?')) {
                    var obj = $(this).parents('tr');
                    //console.log(obj);
                    delAjax(ac_id, obj);
                } else {

                }
            })
        });

        //    执行删除
        function delAjax(id, obj) {
            $.ajax({
                type: 'delete', // DELETE请求方式
                url: '/teachers/' + id,
                dataType: 'json',
                success: function (data) {
                    //console.log(data);
                    if (data.status) {

                        // 将当前的节点删除掉
                        obj.remove();
                    } else {

                    }
                },
                error: function () {
                    // AJAX操作失败
                    alert('AJAX操作失败');
                }
            });
        }


        $(function () {
            $('#doc-prompt-toggle').on('click', function () {
                $('#my-prompt').modal({
                    relatedTarget: this,
                    onConfirm: function () {
                    },
                    onCancel: function () {
                        console.log($("div").children("input.am-modal-prompt-input").val(''));
                    }
                });
            });
        });


        //    分页浮动
        $(".pageination>li").css('float', 'left');
    </script>
    <script>

        // 验证用户名
        function checkUser() {
            var tch_name = document.myform.tch_name.value;
            var utab = document.getElementById('utab');

            if (tch_name.match(/^[\u4e00-\u9fff\w]{2,5}$/) == null) {
                utab.innerHTML = '* 用户名非法!';
                utab.style.color = '#f00';
                return false;
            } else {
                utab.innerHTML = '* 验证通过';
                utab.style.color = '#0a0';
                return true;
            }
        }

        function checkAge() {
            var tch_age = document.myform.tch_age.value;
            var atab = document.getElementById('atab');

            if (tch_age.match(/^\w{2}$/) == null) {
                atab.innerHTML = '* 年龄非法!';
                atab.style.color = '#f00';
                return false;
            } else {
                atab.innerHTML = '* 验证通过';
                atab.style.color = '#0a0';
                return true;
            }
        }


        //验证手机号
        function checkPhone() {
            var tch_phone = document.myform.tch_phone.value;
            var pptab = document.getElementById('pptab');


            if (tch_phone.match(/^1[34578]\d{9}$/) == null) {
                pptab.innerHTML = '* 手机号非法!';
                pptab.style.color = '#f00';
                return false;
            } else {
                pptab.innerHTML = '* 验证通过';
                pptab.style.color = '#0a0';
                return true;
            }

        }

        // 提交时再次根据结果判断
        function checkForm() {
            return checkUser() && checkAge() && checkPhone();

        }

    </script>

</body>

</html>

